//
//  APVideoDetailNaviBar.m
//  AqualPolo
//
//  Created by dong on 2024/5/12.
//

#import "APVideoDetailNaviBar.h"

@interface APVideoDetailNaviBar ()
@property (nonatomic, strong) UIView *contentView;
@end

@implementation APVideoDetailNaviBar

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        _contentView = [[UIView alloc] init];
        [self addSubview:_contentView];
        [_contentView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(20);
            make.left.right.equalTo(self);
            make.height.mas_equalTo(44);
            make.bottom.equalTo(self);
        }];
        
        _backButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_backButton setImage:[UIImage imageNamed:@"back_2"] forState:UIControlStateNormal];
        [_contentView addSubview:_backButton];
        [_backButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_contentView).offset(20);
            make.top.bottom.equalTo(_contentView);
            make.width.mas_equalTo(20);
        }];
        
        _avatarControl = [[APAvatarControl alloc] init];
        _avatarControl.followButton.hidden = true;
        [_contentView addSubview:_avatarControl];
        [_avatarControl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_backButton.mas_right).offset(12);
            make.centerY.equalTo(_contentView);
        }];
        
        _moreButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_moreButton setBackgroundImage:[UIImage imageNamed:@"more_white"] forState:UIControlStateNormal];
        [_contentView addSubview:_moreButton];
        [_moreButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(_contentView).offset(-20);
            make.centerY.equalTo(_contentView);
            make.size.mas_equalTo(CGSizeMake(28, 28));
        }];
        
        _upvoteButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_upvoteButton setBackgroundImage:[UIImage imageNamed:@"video_upvote_n"] forState:UIControlStateNormal];
        [_upvoteButton setBackgroundImage:[UIImage imageNamed:@"video_upvote_h"] forState:UIControlStateSelected];
        [self addSubview:_upvoteButton];
        [_upvoteButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(_moreButton.mas_left).offset(-28);
            make.centerY.equalTo(_moreButton.mas_centerY);
            make.size.mas_equalTo(CGSizeMake(28, 28));
        }];
        
        _nameLabel = [[UILabel alloc] init];
        _nameLabel.textColor = [UIColor whiteColor];
        _nameLabel.font = [LYFont fontWithSize:12 fontName:LYFontNamepfr];
        _nameLabel.textAlignment = NSTextAlignmentLeft;
        [_contentView addSubview:_nameLabel];
        [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.equalTo(_contentView);
            make.left.equalTo(_avatarControl.mas_right).offset(8);
            make.right.equalTo(_upvoteButton.mas_left).offset(-8);
        }];
        
    
        
        
        
        
    }
    return self;
}


- (void)safeAreaInsetsDidChange{
    [super safeAreaInsetsDidChange];
    CGFloat top = self.safeAreaInsets.top > 0 ? self.safeAreaInsets.top:20;
    [_contentView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).offset(top);
    }];
}

@end
